<?php

use Illuminate\Support\Facades\Route;

Route::group(
    ['prefix' => 'warehouse', 'middleware' => ['warehouse', 'logs:warehouse'], 'namespace' => 'App\Http\Controllers\Warehouse'],
    function () {


        // 不登录也可以进入
        Route::group(
            ['middleware' => 'guest:warehouse'],
            function () {
                Route::post('login', 'AuthController@login');
                Route::put('refresh', 'AuthController@refresh');
            }
        );
        // 登录才可以进入
        Route::group(
            ['middleware' => 'auth:warehouse'],
            function () {
                Route::delete('logout', 'AuthController@logout');
                Route::get('profile/logs', 'AuthController@logs');
                Route::get('profile', 'AuthController@profile');
                Route::put('profile/password', 'AuthController@password');
            }
        );
        // 要验证权限
        Route::group(
            ['middleware' => ['rbac:warehouse', 'auth:warehouse'], 'prefix' => 'authorities'],
            function () {
                Route::get('menu/authority', 'Authorities\MenuController@authority')->name('role.menu_authority');
                Route::resource(
                    'role',
                    'Authorities\RoleController',
                    [
                        'names' => [
                            'create' => 'role.store',
                            'edit' => 'role.update',
                        ],
                    ]
                )->except(['show']);
                Route::put('user/{user}/status', 'Authorities\UserController@status')->name('user.update');
                Route::resource(
                    'user',
                    'Authorities\UserController',
                    [
                        'names' => [
                            'create' => 'user.store',
                            'edit' => 'user.update',
                        ],
                    ]
                )->except(['show', 'destroy']);

            }
        );
    }
);
